//
//  GoodsDetailVC.m
//  BonweBuy
//
//  Created by liuxin on 2020/2/24.
//  Copyright © 2020 liuxin. All rights reserved.
//

#import "GoodsDetailVC.h"
#import "GoodsDetailModel.h"
#import "GoodsDetailHeadView.h"
#import "GoodsDetailBottomView.h"

@interface GoodsDetailVC ()
@property (nonatomic, strong) GoodsDetailModel *detailModel;
@property (nonatomic, strong) GoodsDetailHeadView *headView;
@property (nonatomic, strong) GoodsDetailBottomView *bottomView;
@end

@implementation GoodsDetailVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"商品详情";
    //获取json数据
    [self getJsonData];
    //创建头部视图
    [self createHeadView];
    //创建底部视图
    [self createBottomView];
}

#pragma mark - 获取json数据
-(void)getJsonData{
    NSDictionary *detailDic = [AppTools readLocalFileWithName:@"detailData"];
    self.detailModel = [GoodsDetailModel mj_objectWithKeyValues:detailDic[@"result"]];
}

#pragma mark - 创建头部视图
-(void)createHeadView{
    [self.view addSubview:self.headView];
    [_headView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(0);
        make.height.mas_equalTo(kAppWidth_Mini(1516));
    }];
    self.headView.detailModel  =self.detailModel;
}

#pragma mark - 创建底部视图
-(void)createBottomView{
    [self.view addSubview:self.bottomView];
    [_bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(0);
        make.height.mas_equalTo(TABBAR_HEIGHT);
    }];
}

#pragma mark - 蓝加载
-(GoodsDetailHeadView *)headView{
    if (!_headView) {
        _headView = [[GoodsDetailHeadView alloc]init];
    }
    return _headView;
}

-(GoodsDetailBottomView *)bottomView{
    if (!_bottomView) {
        _bottomView = [[GoodsDetailBottomView alloc]init];
    }
    return _bottomView;
}

@end
